<script>
import commonNav from "@/components/nav/commonNav.vue"
import storage from "@/utils/storage.js"

export default {
  components: {
    commonNav
  },
  data() {
    return {
      navTitle: this.$t('home.cacheList'),
      data: [{}],
      defectiveSpotList: [],
      processesList: [],
      queryParams: {
        sewingId: this.sewingId,
      },
      currentSewLine: storage.get('currentSewLineInfo') || {
        sewingName: '未选择缝制线'
      },
    }
  },
  mounted() {
    // console.log('mounted');
    // this.data = uni.getStorageSync('offlineCaching')[this.queryParams.sewingId] || {}
  },
  onShow() {
    const currentSewingId = storage.get('currentSewingId')
    // console.log('onShow', currentSewingId);
    this.data = uni.getStorageSync('offlineCaching')[currentSewingId] || []

    // uni.$u.toast('currentSewingId: ' + currentSewingId + '  length: ' + this.data.length);
  },
  onLoad(option) {
    this.queryParams.sewingId = option.sewingId
  },
  methods: {
    // 查看详情
    viewRecordDetail(defectiveSpotList, processesList) {
      this.defectiveSpotList = defectiveSpotList
      this.processesList = processesList
      this.$refs.recordDetail.open()
    },
    // 跳转修改记录
    toUpdateRecord(data) {
      storage.set('cacheDetail', data)
      uni.navigateTo({
        url: `/pages/cacheList/cacheDetail`
      })
    },
    backToHome() {
      uni.navigateTo({
        url: `/pages/index/index`
      })
    },
  }
}

</script>

<template>
  <view class="page">
    <commonNav :currentSewLine="currentSewLine.sewingName" :navTitle="navTitle" @backRouter="backToHome" />
    <view class="table">
			<uni-table :stripe="false" :emptyText="$t('common.noData')">
				<!-- 表头行 -->
				<!-- <u-sticky> -->
					<uni-tr class="fixed-th">
						<!-- 序号 单号 款号 款名 客户 颜色 尺码 合格 返工 报废 登记时间 -->
						<uni-th width="50px" align="center">{{ $t('pages.quality.no') }}</uni-th>
						<uni-th width="100px" align="center">{{ $t('pages.quality.productionNo') }}</uni-th>
						<uni-th width="100px" align="center">{{ $t('pages.quality.styleNo') }}</uni-th>
						<uni-th width="140px" align="center">{{ $t('pages.quality.styleName') }}</uni-th>
						<uni-th width="100px" align="center">{{ $t('pages.quality.customer') }}</uni-th>
						<uni-th width="80px" align="center">{{ $t('pages.quality.color') }}</uni-th>
						<uni-th width="80px" align="center">{{ $t('pages.quality.size') }}</uni-th>
						<uni-th width="70px" align="center">{{ $t('pages.quality.pass') }}</uni-th>
						<uni-th width="70px" align="center">{{ $t('pages.quality.rework') }}</uni-th>
						<uni-th width="70px" align="center">{{ $t('pages.quality.scarp') }}</uni-th>
						<!-- <uni-th width="120px" align="center">{{ $t('pages.quality.regTime') }}</uni-th> -->
						<uni-th width="160px" align="center">{{ $t('common.operate') }}</uni-th>
					</uni-tr>
				<!-- </u-sticky> -->
				<!-- 表格数据行 -->
				<uni-tr v-for="(item, index) in data" :key="index">
					<uni-td align="center">{{index + 1}}</uni-td>
					<uni-td align="center">{{ item.billNo }}</uni-td>
					<uni-td align="center">{{ item.styleNo }}</uni-td>
					<uni-td align="center">{{ item.styleName }}</uni-td>
					<uni-td align="center">{{ item.customerName }}</uni-td>
					<uni-td align="center">{{ item.color }}</uni-td>
					<uni-td align="center">{{ item.size }}</uni-td>
					<uni-td align="center">{{ item.qualifiedNum || 0 }}</uni-td>
					<uni-td align="center">{{ item.unqualifiedNum || 0 }}</uni-td>
					<uni-td align="center">{{ item.discardedNum || 0 }}</uni-td>
					<!-- <uni-td align="center">{{ item.createDate }}</uni-td> -->
					<uni-td align="center">
						<view class="td-handle">
							<!-- <u-button class="isLink">isLink</u-button> -->
							<!-- <i class="t-icon t-icon-canshujilu" @click="viewRecordDetail(item.defectiveSpotList, item.processesList)"></i> -->
							<i class="t-icon t-icon-canshujilu" @click="toUpdateRecord(item)"></i>
							<!-- <i class="t-icon t-icon-shanchu"  @click="delItem(item,index)"></i> -->
						</view>
					</uni-td>
					<!-- 折叠表 -->
				</uni-tr>
			</uni-table>
		</view>
  </view>
</template>


<style lang="scss" scoped>
	.page {
    position: relative;
		width: 100%;
		// height: 100vh;
		overflow-x: hidden;
		// box-sizing: border-box;
	}
	/deep/.u-sticky__content {
		// padding-top: 10%;
	
	}
	.fixed-th {
		// position: fixed;
	}
	.table {
    margin-top: 6%;
		// margin: 1% 0;
		.td-handle {
			display: flex;
			justify-content: space-evenly;
		}
	}

	/deep/ .uni-table-th-content {
		font-size: 1rem;
	}

	.uni-table-td {
		font-size: 1rem;
	}

	/deep/ .u-tabs__wrapper__nav__item__text {
		font-size: 1.2rem;
	}
</style>